
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    withdraw:0,
    price:null,
    wechat: ''
  },
  onLoad: function (options) {
    this.setData({
      withdraw:options.value
    })
  },
  toAllWithdraw(){
    this.setData({
      price:this.data.withdraw
    })
  },
  withDraw(){
    let _this = this;
    if(Number(_this.data.price)>Number( _this.data.withdraw) || Number(_this.data.price) > 1000){
      wx.showToast({
        icon:'none',
        title: '超出可提现金额',
      })
      return
    }
    if (_this.data.wechat === '') {
      wx.showToast({
        title: '请输入微信账号',
        icon: 'none'
      })
      return
    }
      app.util.request({
        url: 'api/bring/add',
        method: "post",
        data: {
          price: _this.data.price,
          weChat: _this.data.wechat,
          page:1,
          pageSize:10,
        },
        success(response) {
            if (response.data.code == 0) {
              // wx.showToast({
              //   title: '您已经成功申请提现操作, 请耐心等待人工审核以及审核结果的推送信息！',
              // })
              wx.showModal({
                title: '温馨提示',
                content: '您已经成功申请提现操作, 请耐心等待人工审核以及审核结果的推送信息！',
                showCancel: false,
                confirmText: '我知道了'
              })
              _this.setData({
                total:response.data.data[0].balance,
                withdraw:response.data.data[0].withdraw,
                wallet_list:response.data.data[0].record.list
              })
            } else {
              wx.showToast({
                title: response.data.msg,
                icon: 'none'
              })
            }
        }
      })
    }
})